package com.fast.common.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * controller 統一返回F
 *
 * @author liming
 */
public class F extends HashMap<String, Object> {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public F() {
        put("code", 0);
        put("msg", "success");
    }

//    public static F error() {
//        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
//    }
//
//    public static R error(String msg) {
//        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
//    }

    public static F error(int code, String msg) {
        F f = new F();
        f.put("code", code);
        f.put("msg", msg);
        return f;
    }

    public static F ok(String msg) {
        F f = new F();
        f.put("msg", msg);
        return f;
    }

    public static F ok(Map<String, Object> map) {
        F f = new F();
        f.putAll(map);
        return f;
    }

    public static F ok() {
        return new F();
    }

    public F put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
